package server.conf;

import java.util.MissingResourceException;
import java.util.ResourceBundle;

/**
 * Class that manages error resources.
 * Resoruces are kept in server.conf.error.properties file.
 * 
 * @author Kamil Nowak
 * 
 */
public class Error {
	private static final String BUNDLE_NAME = "server.conf.error"; 

	private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
			.getBundle(BUNDLE_NAME);

	private Error() {
	}

	/**
	 * Returns error message corresponding key value
	 * @param key 
	 * @return error message or !key! if mapping does not exist
	 */
	public static String getString(String key) {
		
		try {
			return RESOURCE_BUNDLE.getString(key);
		} catch (MissingResourceException e) {
			return '!' + key + '!';
		}
	}
}
